//导入fs
const fs = require('fs')

//读取素材的内容
fs.readFile(__dirname + '/素材/成绩.txt', 'utf-8', (err, dataStr) => {
  err && console.log(err)
  console.log(__dirname)
  // console.log(dataStr.split(' '))
  // 把内容转成数组形式
  const arr = dataStr.split(' ')
  const newArr = arr.map(item => item.replace('=', ':'))
  // console.log(newArr.join('\r\n'))
  fs.writeFile(__dirname + '/files/成绩.txt', newArr.join('\r\n'), 'utf-8', err =>
    err ? console.log(err) : console.log('写入成功')
  )
})
